<?php

class Mail {

	public $to;
	public $from;
	public $subject;
	public $body;
	public $additional_headers;
	public $additional_parameters;
	public $html = false;
	public $charset = "UTF-8";

	public function __construct ($to = "", $from = "", $subject = "", $body = "", $additional_headers = "", $additional_parameters = "") {
		$this->to = $to;
		$this->from = $from;
		$this->subject = $subject;
		$this->body = $body;
		$this->additional_headers = $additional_headers;
		$this->additional_parameters = $additional_parameters;
	}

	public function send () {
		$to = is_array($this->to) ? join(', ', $this->to) : $this->to;
		$subject = $this->subject;
		$message = $this->body;

		$headers = "Content-type: " . ($this->html ? "text/html" : "text/plain") . "; charset={$this->charset} \r\n";
		$headers .= "From: {$this->from}\r\n";

		try {
			mail($to, $subject, $message, $headers);
		} catch (Exception $exc) {
			echo $exc->getTraceAsString();
		}
	}

}